home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
081-090
/
amok81
/
m2
/
talkdemo
/
txt
/
talkfile.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
4KB
|
176 lines
IMPLEMENTATION MODULE TalkFile;
(*$ LargeVars:=FALSE StackParms:=FALSE Volatile:=FALSE *)
FROM SYSTEM IMPORT ADR,ADDRESS,CAST;
FROM IconL IMPORT FreeDiskObject,GetDiskObject,PutDiskObject;
FROM String IMPORT noOccur,Concat,LastPos;
FROM WorkbenchD IMPORT DiskObjectPtr;
IMPORT
A:Arts,
TB:TalkBase,
TG:TalkGadgets,
ASLReq2,
S:String,
Req:Requester,
DD:DosD,
DL:DosL,
IL:IconL,
WD:WorkbenchD;
CONST
phonMagic =CAST(LONGINT,"PHN.");
voiceMagic=CAST(LONGINT,"VCE.");
defIcon="DefIcon";
TYPE
PhonFile=RECORD
magic:LONGINT;
phon:TB.Str255;
END;
VoiceFile=RECORD
magic:LONGINT;
voice:TB.NarrData;
END;
Str128 = ARRAY [0..127] OF CHAR;
VAR
phonName :=Str128{".phn"};
voiceName:=Str128{".vce"};
fh:DD.FileHandlePtr;
phon:PhonFile;
voice:VoiceFile;
PROCEDURE MakeIcon(name: ARRAY OF CHAR);
VAR
do: WD.DiskObjectPtr;
(*$ CopyDyn:=FALSE *)
BEGIN
do:=IL.GetDiskObject(ADR(name));
IF do=NIL THEN (* noch keins da. *)
do:=IL.GetDiskObject(ADR(defIcon));
IF do#NIL THEN
IF IL.PutDiskObject(ADR(name),do) THEN END;
IL.FreeDiskObject(do)
END;
ELSE (* gibt es schon, alles klar. *)
IL.FreeDiskObject(do);
END;
END MakeIcon;
PROCEDURE CloseFile;
BEGIN
IF fh#NIL THEN
DL.Close(fh);
fh:=NIL
END;
END CloseFile;
PROCEDURE GetVoice():BOOLEAN;
VAR
ok:BOOLEAN;
BEGIN
fh:=DL.Open(ADR(voiceName),DD.oldFile);
ok:=(fh#NIL)&(DL.Read(fh,ADR(voice),SIZE(voice)) = SIZE(voice))
&(voice.magic=voiceMagic);
CloseFile;
RETURN ok;
END GetVoice;
PROCEDURE PutVoice():BOOLEAN;
VAR
ok:BOOLEAN;
BEGIN
fh:=DL.Open(ADR(voiceName),DD.newFile);
ok:=(fh#NIL)&(DL.Write(fh,ADR(voice),SIZE(voice)) = SIZE(voice));
CloseFile;
IF ok THEN MakeIcon(voiceName) END;
RETURN ok;
END PutVoice;
PROCEDURE GetPhonemes():BOOLEAN;
VAR
ok:BOOLEAN;
BEGIN
fh:=DL.Open(ADR(phonName),DD.oldFile);
ok:=(fh#NIL)&(DL.Read(fh,ADR(phon),SIZE(phon))=SIZE(phon))
&(phon.magic=phonMagic);
CloseFile;
RETURN ok;
END GetPhonemes;
PROCEDURE PutPhonemes():BOOLEAN;
VAR
ok:BOOLEAN;
BEGIN
fh:=DL.Open(ADR(phonName),DD.newFile);
ok:=(fh#NIL)&(DL.Write(fh,ADR(phon),SIZE(phon))=SIZE(phon));
IF ok THEN MakeIcon(phonName) END;
CloseFile;
RETURN ok;
END PutPhonemes;
PROCEDURE SavePhonemes;
BEGIN
TB.SetBusy(TRUE);
IF S.Length(TB.phonBuff)>0 THEN
IF ASLReq2.FileReq(phonName,"Save Phonemes","#?.phn",TRUE) THEN
phon.magic:=phonMagic;
phon.phon:=TB.phonBuff;
IF ~PutPhonemes() THEN
Req.OKRequest("Kann Datei nicht sichern!")
END;
END;
ELSE
Req.OKRequest("Keine Phoneme definiert!");
END;
TB.SetBusy(FALSE);
END SavePhonemes;
PROCEDURE LoadPhonemes();
BEGIN
TB.SetBusy(TRUE);
IF ASLReq2.FileReq(phonName,"Load Phonemes","#?.phn",FALSE) THEN
IF GetPhonemes() THEN
TB.phonBuff:=phon.phon;
TG.UpdatePhonemes;
ELSE
Req.OKRequest("Datei nicht zu laden\noder falscher Schlüssel!");
END;
END;
TB.SetBusy(FALSE);
END LoadPhonemes;
PROCEDURE SaveVoice;
BEGIN
TB.SetBusy(TRUE);
IF ASLReq2.FileReq(voiceName,"Save Voice","#?.vce",TRUE) THEN
voice.magic:=voiceMagic;
voice.voice:=TB.myNarr;
IF ~PutVoice() THEN
Req.OKRequest("Kann Datei nicht sichern!")
END;
END;
TB.SetBusy(FALSE);
END SaveVoice;
PROCEDURE LoadVoice;
BEGIN
TB.SetBusy(TRUE);
IF ASLReq2.FileReq(voiceName,"Load Voice","#?.vce",FALSE) THEN
IF GetVoice() THEN
TB.myNarr:=voice.voice;
TG.SetNarr(TB.myNarr);
ELSE
Req.OKRequest("Datei nicht zu laden\noder falscher Schlüssel!");
END;
END;
TB.SetBusy(FALSE);
END LoadVoice;
BEGIN
CLOSE
CloseFile;
END TalkFile.mod